package com.project.web.admin.utils.convert;

import com.project.common.web.utils.exportView.convert.Convert;
import com.project.web.admin.service.core.StdCodeService;
import org.apache.commons.lang3.StringUtils;
import org.yun.common.utils.SpringUtils;

import java.util.Map;

/**
 * 标准编码的字符串类型转化
 */
public class StdCodeStringConvert implements Convert {

    private StdCodeService stdCodeService;

    private Map<String, String> map;

    public StdCodeStringConvert(String stdCode) {
        if (StringUtils.isNotBlank(stdCode)) {
            stdCodeService = SpringUtils.getBean("stdCodeServiceImpl", StdCodeService.class);
            map = stdCodeService.getMap(stdCode, true);
        }
    }

    @Override
    public String convert(String value) {
        return map.get(value);
    }

}